package com.ant.map.myuiimmersive.activities;

import android.content.Context;
import android.graphics.PixelFormat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;

import com.ant.map.myuiimmersive.R;
import com.ant.utls.base.BaseActivity;
import com.ant.utls.utils.AntLog;

/**
 * Created by baichuan on 2016/12/9.
 */

public class Test004 extends BaseActivity implements View.OnClickListener {
    private Button obt;
    private Context context;

    private View wview;
    private WindowManager wm;
    private WindowManager.LayoutParams layout;

    @Override
    public int getLaout() {
        return R.layout.ac_test004;
    }

    @Override
    public void initView() {
        obt = (Button) findViewById(R.id.ac_test004_obt01);
        wview = LayoutInflater.from(this).inflate(R.layout.ac_view001, null);

    }

    @Override
    public void initData() {
        wm = (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVICE);
        layout = new WindowManager.LayoutParams();
        layout.type = WindowManager.LayoutParams.TYPE_PHONE;
        layout.format = PixelFormat.RGBA_8888;
        layout.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        layout.gravity = Gravity.LEFT | Gravity.TOP;

        layout.width = WindowManager.LayoutParams.WRAP_CONTENT;
        layout.height = WindowManager.LayoutParams.WRAP_CONTENT;

    }

    @Override
    public void initListener() {
        obt.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ac_test004_obt01:
                wm.addView(wview, layout);
                AntLog.i("add view to  windows ");
                break;
        }
    }
}
